﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Mjudoku
{
    class SimpleModel : Model
    {
        private int[,] gameArray;
        private bool[,] editableNumbers;
        private int blockSize;

        public int[,] getCisla()
        {
            return gameArray;
        }

        public bool[,] getEditable()
        {
            throw new NotImplementedException();
        }

        public void loadSudoku(Object source)
        {
            gameArray = (int[,])source;

            for (int i = 0; i < gameArray.GetLength(0); i++)
            {
                for (int j = 0; j < gameArray.GetLength(1); j++)
                {
                    editableNumbers[i,j] = gameArray[i, j] == 0 ? true : false;
                }
            }

        }

        public int getNumber(int row, int column)
        {
            return gameArray[row, column];
        }

        public bool isEditable(int row, int column)
        {
            return editableNumbers[row, column];
        }

        public int getSize()
        {
            return gameArray.GetLength(0);
        }

        public int getBlockSize()
        {
            return blockSize;
        }


        private bool checkSize(int blockSize, int arraySize)
        {
            return true;
        }

        public void initArray(int blockSize, int arraySize)
        {
            if (checkSize(blockSize, arraySize))
            {
                gameArray = new int[arraySize, arraySize];
                editableNumbers = new bool[arraySize, arraySize];
                this.blockSize = blockSize;
            }
            else
            {
                throw new Exception("Illegal size of game array.");
            }
        }

        public void editNumber(int row, int column, int newValue)
        {
            gameArray[row, column] = newValue;
        }
    }
}
